<?php

namespace app\modules\admin\models;

use Yii;

/**
 * This is the model class for table "admin_role".
 *
 * @property int $id 角色id
 * @property string $role_id
 * @property string $role_name 角色名称
 * @property int $deleted 是否删除
 * @property string $created 创建时间
 * @property string $modified 修改时间
 */
class AdminRole extends BaseModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'admin_role';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['role_id', 'role_name'], 'required'],
            [['deleted'], 'integer'],
            [['created', 'modified'], 'safe'],
            [['role_id'], 'string', 'max' => 50],
            [['role_name'], 'string', 'max' => 100],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', '角色id'),
            'role_id' => Yii::t('app', 'Role ID'),
            'role_name' => Yii::t('app', '角色名称'),
            'deleted' => Yii::t('app', '是否删除'),
            'created' => Yii::t('app', '创建时间'),
            'modified' => Yii::t('app', '修改时间'),
        ];
    }



    public function getRoleList($offset, $limit, $isCount = false)
    {
        $obj = $this->orm();
        if ($isCount) {
            $result = $obj->count();
        } else {
            $result = $obj->offset($offset)
                ->limit($limit)
                ->findArray();
        }
        return $result;
    }
}
